package tech.wetech.admin.modules.system.web;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import tech.wetech.admin.core.annotation.SystemLog;
import tech.wetech.admin.core.utils.Result;
import tech.wetech.admin.modules.base.web.BaseCrudController;
import tech.wetech.admin.modules.system.po.AndroidList;
import tech.wetech.admin.modules.system.service.AndroidListService;

import javax.validation.constraints.NotNull;

/**
 * @author lu
 * @description
 * @date 2019年08月09日 9:43
 */
@Api(value = "安卓机白名单", description = "安卓机白名单管理基本信息操作API")
@Controller
@RequestMapping("/android")
public class AndroidListController extends BaseCrudController<AndroidList> {

    @Autowired
    private AndroidListService androidListService;

    @GetMapping
    public String userPage(Model model) {
        return "system/android";
    }

    @ResponseBody
    @ApiOperation(value="安卓机白名单新增",notes="安卓机白名单新增")
    @RequiresPermissions("android:create")
    @SystemLog("安卓机白名单新增")
    @PostMapping("/create")
    @Override
    public Result create(@Validated AndroidList androidList) {
        androidListService.createAndroidList(androidList);
        return Result.success();
    }

    @ResponseBody
    @RequiresPermissions("android:update")
    @ApiOperation(value="安卓机白名单修改",notes="安卓机白名单修改")
    @SystemLog("安卓机白名单修改")
    @PostMapping("/update")
    @Override
    public Result update(@Validated AndroidList androidList) {
        androidListService.updateNotNull(androidList);
        return Result.success();
    }

    @ResponseBody
    @RequiresPermissions("android:delete")
    @SystemLog("角色管理删除角色")
    @PostMapping("/delete-batch")
    @Override
    public Result deleteBatchByIds(@NotNull @RequestParam("id") Object[] ids) {
        super.deleteBatchByIds(ids);
        return Result.success();
    }
}
